package com.chixing.ih.module.task.mapper.provider;

import org.apache.ibatis.jdbc.SQL;

/**
 * 目的:
 *
 * @author ：zcw
 * @version: 1.0  2020/9/25 23:03
 */
public class CommentMapperProvider {

    public String findByTaskId() {
        return new SQL() {{
            SELECT("*");
            FROM("tbl_comment");
            WHERE("task_id = #{taskId}");

        }}.toString();
    }

    public String findSecondComment() {
        return new SQL() {{
            SELECT("*");
            FROM("tbl_reply");
            WHERE("reply_comment_id = #{commentId}", "reply_top=2");
        }}.toString();
    }


    public String findThirdComment() {
        return new SQL() {{
            SELECT("*");
            FROM("tbl_reply");
            WHERE("reply_comment_id = #{commentId}", "reply_top=1");
        }}.toString();
    }


    public String addSonComments() {
        return new SQL() {{
            INSERT_INTO("tbl_reply");
            INTO_COLUMNS("reply_content", "reply_comment_id", "reply_replyuser_id", "user_id", "reply_top");
            INTO_VALUES("replyContent", "replyCommentId", "replyReplyUserId", "userId", "replyTop");
        }}.toString();
    }


    public String addRootComments() {
        return new SQL() {{
            INSERT_INTO("tbl_comment");
            INTO_COLUMNS("comm_context", "task_id", "user_id");
            INTO_VALUES("commContext", "taskId", "userId");
        }}.toString();
    }


}
